###############################################################
# Clase GET_UVG_Answer
# representa una respuesta hacia otro servidor. Es la respuesta
# a una petición GET_UVG.
###############################################################
class GET_UVG_Answer

	def initialize(server_name)
		@HTTP_code = ""
		@server_name = server_name
	end
		
	
	#------------------------------------------------------
	# retorna ya sea @HTTP_code  o @content
	#------------------------------------------------------
	attr_reader :HTTP_code, :content, :authentication
	attr_writer :HTTP_code, :content, :authentication
	
	def setHTTP_code(code)
		case code.downcase

			
		when "ok"
			@HTTP_code = "HTTP/1.1 200 OK"
			
		when "cant create user"
			@HTTP_code = "HTTP/1.1 4400 CANT_CREATE_USER"
			
		when "cant update user"
			@HTTP_code = "HTTP/1.1 4401 CANT_UPDATE_USER"
			
		when "cant delete user"
			@HTTP_code = "HTTP/1.1 4402 CANT_DELETE_USER"
			
		when "error"
			@HTTP_code = "HTTP/1.1 4403 PROTOCOL_ERROR"
		end
		addHeader("Host","#{@server_name}:8080")
	end
	
	#------------------------------------------------------
	# agrega al final de la respuesta el header solicitado
	#------------------------------------------------------
	def addHeader(header_name, header_content)
		@HTTP_code << "\r\n"
		@HTTP_code << "#{header_name}: #{header_content}"
	end
	
	#------------------------------------------------------
	# retorna la respuesta completa
	#------------------------------------------------------
	def answer()
		var = "#{@HTTP_code}"
		var << "\n"
		return var
	end
end
